@extends('app')

@section('content')
<ul class="nav nav-tabs">
    <li ><a href="{{ url('/admin/enterprise/company_type')}}">分类列表</a></li>
    <li class="active"><a href="{{ url('/admin/enterprise/company_type/create') }}">添加分类</a></li>
</ul>
<form method="POST" action="{{ url('/admin/enterprise/company_type') }}" class="form-inline">
    <div class="panel panel-default mt20">
    <div class="main">
        <div class="form-group">
            <label>分类名称：</label>
            <input type="text" class="form-control" name="cat_name" id="cat_name" @if(!empty($cate_name)) value="{{ $cate_name }}" @endif>
        </div>
        
        @if($blademode == "edit")
        <input type="hidden" name="cat_id" value="{{ $cate_id }}">
        <div class="form-inline mt20">
            <div class="form-group" id="parent">
                <label>选择分类：</label>
                <select name="type" class="form-control" id="type" onchange="getCompanyTypeChilds(this.value,'parent',)">
                    <option value="0">主分类</option>
                    @foreach($type as $tp)
                    <option value="{{ $tp->id }}" @if(($tp->id == $cates->id) && $up > 0) selected @endif>{{ $tp->name }}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group ml30" id="child_1">
                @if(count($upcategory) > 0)
                <select name="child_1" class="form-control" id="child_1" onchange="getCompanyTypeChilds(this.value,child)">
                    <option value="0">请选择分类</option>
                    @foreach($upcategory as $upc)
                    <option value="{{ $upc->id}}"  @if($upc->id == $second_cates->id ) selected @endif>{{$upc->name}}</option>
                    @endforeach
                </select>
                @endif
            </div>
        </div>
        @else
        @if(!empty($cates) && count($cates)>0)
        <div class="form-inline mt20">
            <div class="form-group" id="parent">
                <label>上级分类：</label>
                <select name="type" class="form-control" id="type">
                    <option value="{{ $cates->id }}" selected>{{ $cates->name }}</option>
                </select>
            </div>
        </div>
        @else
        <div class="form-inline mt20">
            <div class="form-group" id="parent">
                <label>上级分类：</label>
                <select name="type" class="form-control" id="type" onchange="getCompanyTypeChilds(this.value,'parent')">
                    <option value="0">主分类</option>
                    @foreach($type as $tp)
                    <option value="{{ $tp->id }}">{{ $tp->name }}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group ml30" id="child_1"></div>
            <div class="form-group ml30" id="child_2"></div>
            <div class="form-group ml30" id="child_3"></div>
        </div>
        @endif
        @endif
        <div class="form-inline mt20">
            <div class="form-group">
                <label>分类排序：</label>
                <input type="number" class="form-control" name="sort" id="sort" @if(isset($cate_sort)) value="{{ $cate_sort }}" @endif>
            </div>
        </div>
        <div class="form-inline mt20">
            <div class="form-group">
                <label>关&nbsp;&nbsp;键&nbsp;&nbsp;词：</label>
                <textarea rows="5" cols="20" name="identify" class="form-control">@if(isset($identify)) {{ $identify }} @endif</textarea>
            </div>
        </div>
        <div class="form-inline mt20">
            <div class="form-group">
                <label>描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述：</label>
                <textarea rows="5" cols="20" name="description" class="form-control">@if(isset($description)) {{ $description }} @endif</textarea>
            </div>
        </div>
    </div>
    </div>
    {!! csrf_field() !!}
    <div class="form-inline mt20">
        <div class="form-group">
            <input type="hidden" name="stauts" value="1">
            <input type="submit" class="btn btn-primary btn-block" id="save" value="保存" />
        </div>
        <div class="form-group ml30">
            <input type="reset" class="btn btn-default btn-block" value="重置" />
        </div>
    </div>
</form>
@endsection
